//-------------------------------------------------------------------
//	Copyright (c) 2012-2014 Zhirnov Andrey
//	This file is part of the "UXGEN-ES" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#pragma once

#include "UI/Types/Types.h"

namespace Engine
{
namespace UI
{

	class UILocaleResource;
	SHARED_POINTER( UILocaleResource );



	//
	// UI Localization Resource
	//

	class UILocaleResource : public Resource
	{
		friend struct ::MetaData::UILocaleCfg;
		
	// types
	public:
		struct UILocaleLoadParams : ResLoadParams
		{
		// methods
		public:
			UILocaleLoadParams () : ResLoadParams( Signature() )
			{}

			static signature_t Signature ()
			{
				return CompileTime::TSignature8< 'U', 'I', 'L', 'O', 'C', 'A', 'L', 'E' >::value;
			}
		};


	// variables
	private:
		array<ext_string>		_strings;


	// methods
	public:
		UILocaleResource (const EngineSubSystemsRef ess) :
			Resource( EResource::UI_LOCALE, ess )
		{}

		~UILocaleResource ()
		{}


		array<ext_string> const &	GetStrings () const
		{
			return _strings;
		}

		
		virtual bool SwapData (const ResourcePtr &res) override
		{
			CHECK_ERR( Resource::SwapData( res ) );

			UILocaleResource *	locale = res.ToPtr< UILocaleResource >();

			this->_strings.SwapMem( locale->_strings );
			return true;
		}


		virtual bool IsLoadedWithParams (const ResLoadParams &params) const override
		{
			return true;
		}
		

		virtual bool IsValid () const override
		{
			return not _strings.Empty();
		}


		static UILocaleResourcePtr New (const EngineSubSystemsRef ess)
		{
			return BaseObject::_New( new UILocaleResource( ess ) );
		}


		static UILocaleLoadParams GetDefaultLoadParams ()
		{
			return UILocaleLoadParams();
		}
	};


}	// UI
}	// Engine